//169.多数元素
//https://leetcode.cn/problems/majority-element/?envType=study-plan-v2&envId=top-interview-150
class Solution {
public:
    int majorityElement(vector<int>& nums) {
        unordered_map<int,int> hash;
        int maxn = nums.front();
        for(int& n:nums) 
        {
            ++hash[n];
            if(hash[maxn] < hash[n]) maxn = n;
        }
        return maxn;
    }
};